


let os = require("os");
let fs = require("fs")
let path = require("path")
let homedir = os.homedir()
let worldDir = path.resolve(homedir, "./AppData/Roaming/7DaysToDie/GeneratedWorlds")




if (fs.existsSync(worldDir)) {
    let cust_worlds = fs.readdirSync(worldDir)
    cust_worlds = cust_worlds.map(v => {
        let worldName = v;
        let dirPath = path.resolve(worldDir,"./" + worldName)
        let stats = fs.statSync(dirPath)
        return {
            name: worldName,
            path: dirPath,
            ctime: stats.ctime
        }
    })
    cust_worlds = cust_worlds.sort((b,a) => a.ctime - b.ctime)

    console.log(cust_worlds);

}